﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SiteContent.Master" Inherits="System.Web.Mvc.ViewPage<ProjectFitus.Models.ArticleContent>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Brjostagjof.is | Grein | <%= Model.title %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <p>
        <%if (User.IsInRole("Administrators"))
          { %>

            <%= Html.ActionLink("Breyta", "Edit", new { id = Model.id })%> |
            <%= Html.ActionLink("Aftur í greinalista", "Index")%>
        <%} %>
    </p>
    <h2><%= Html.Encode(Model.title) %></h2>
    <h5><%= Html.Encode(String.Format("{0:g}", Model.dateCreated)) %></h5>
    <p>
        <%= Server.HtmlDecode(Model.contentText) %>
    </p>
    
    <hr />

    <p>
        <b>Skráð af: </b><%: ViewData["Author"] %><br />
        <b>Flokkur: </b><%: ViewData["SelectedCategoryName"] %><br />
        <b>Höfundar: </b><% 
                             foreach (var author in ViewData["AuthorList"] as IEnumerable<ProjectFitus.Models.User>)
                             {  %>
                                <%: Html.ActionLink(author.firstName + " " + author.lastName, "Details/" + author.id,"User") %>,                                   
                          <% } %><br />

        <%// ToDo: eftir að útfæra teljara  %>
        <%//<b>Þessi grein hefur verið skoðuð: </b><%: Html.Encode(Model.viewCount) %><%//<br />%>
        <b>Síðast breytt: </b><%: Html.Encode(String.Format("{0:g}", Model.lastDateEdited)) %><br />
        <b>Hver breytti síðast: </b><%= Html.Encode(Model.lastEditedByUserId) %><br />
        <% string strActive = (Model.isActive) ? "Já" : "nei"; %>
        <b>Er virk?:</b><%=strActive %> <br />

    </p>
    <hr />

    <h3>Athugasemdir:</h3>

    <ul class ="comment">
        <%foreach(var item in Model.ArticleComments)
          {%>

         <li class="commentLi">
                <div class="commentBody">
                   Skrifað af: <%: Html.ActionLink(item.User.userName, "details/"+item.commentedBy, "User") %>
                       <h5><%: String.Format("{0:g}", item.dateCommented)%></h5>
                              
                                    <p><%: item.commentText  %> </p>

                </div>
                        <%} %>
         </li>
  </ul>

  <% using (Html.BeginForm())
     {%>
        <%: Html.ValidationSummary(true)%>
        

  <ul class= "comment">
			<li class="commentAdd">
            <% 
                if (Request.IsAuthenticated)
                {
             %>
            <input type="hidden" id="articleId" name="articleId" value="<%: Model.id %>" />
				<textarea id="commentText" name="commentText"></textarea>
				<label>
                    <input type="submit" value="Skrá athugasemd" id="athTakki"/>
				</label>
            <% } %>
			</li>
		</ul>
        <%} %>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

